//
//  BaseTableViewController.swift
//  云Sir的微博
//
//  Created by 赵云 on 15/10/8.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit
////
class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {
    
    //设置用户登陆标记
//    var userLogOn = UserAccount.loadAccount() != nil
    var userLogOn = UserAccount.userLogon
    //定义访客视图
    var visitorView: VisitorLoginView?
    
    override func loadView() {
        
        //根据用户登陆看是否替换根视图
        userLogOn ? super.loadView() : setupVisitorView()
    
    }
    //设置访客的视图
    private func setupVisitorView(){
        
        visitorView = VisitorLoginView()
        
        visitorView?.delegate = self
        
        view = visitorView
        
        /// 设置状态栏
        //UIBarButtonItemStyle.Plain 表示设置为纯文本
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")

    }
    
    //MARK: - VisitorLoginViewDelegate
    func visitorLoginViewWillLogin() {
        
        let nav = UINavigationController(rootViewController:OAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    }

    func visitorLoginViewWillRegister() {
        print("注册")
    }
}
